<!-- MAKE SURE THE RANK IS RIGHT -->

<div data-role="panel" id="mypanel" data-position="right" data-display="overlay">
<h3>Reconcile</h3>
  <form name=coinform action="reconner.php" method="post">
<table border=0>
<tr>
<td align=center>R200</td>
<td align=center>R100</td>
<td align=center>R50</td>
<td align=center>R20</td></tr><td align=center><input type=text name=twun size=3></td>
<td align=center><input type=text name=hun size=3></td>
<td align=center><input type=text name=fif size=3></td>
<td align=center><input type=text name=twe size=3></td><tr>
<td align=center>R10</td>
<td align=center>R5</td>
<td align=center>R2</td>
<td align=center>R1</td>
</tr>
<tr>
<td align=center><input type=text name=ten size=3></td>
<td align=center><input type=text name=fiv size=3></td>
<td align=center><input type=text name=two size=3></td>
<td align=center><input type=text name=one size=3></td>
</tr>

<tr>
<td colspan=8 align=center>
<input type="hidden" name="total2" id="total2" >
<input type=button name=calc value="Calculate" onClick="javascript:money(this.form)">
<input type=text name=total id=total size=10>
<input type=submit name=submit value="Submit">
</td>
</tr>
</table>
</form>
</div>
 <SCRIPT LANGUAGE="JavaScript">



<!-- Begin
function s(num, val) {
amount = num * 1; // amount is the num or NaN
sum = (!num ? 0 : num) * val;  // the sum for that bill or coin

if (isNaN(amount)) { // if the entire is not a number

alert(
"' " + num + " ' is not a valid entry and that field will "
+ "not be included in the total money calculation."
);

return 0;
}
else
return sum; // if it is OK, send sum back
}

function money(form) {
twun = s(form.twun.value, 200); // Each amount is the returned value
hun = s(form.hun.value, 100); // Each amount is the returned value
fif = s(form.fif.value, 50);  // for the amount in the s() function
twe = s(form.twe.value, 20);
ten = s(form.ten.value, 10);
fiv = s(form.fiv.value, 5);
two = s(form.two.value, 2);
one = s(form.one.value, 1);


// add up all the amounts
var ttl = twun + hun + fif + twe + ten + fiv + two
+ one;

// rounds total to two decimal places

ttl = "" + ((Math.round(ttl * 100)) / 100);

dec1 = ttl.substring(ttl.length-3, ttl.length-2);
dec2 = ttl.substring(ttl.length-2, ttl.length-1);

if (dec1 != '.') { // adds trailing zeroes if necessary
if (dec2 == '.') ttl += "0";
else ttl += ".00";
}
form.total.value = ttl; // display total amount
form.total2.value = ttl; // display total amount
}
//  End -->
</script>